//
//  StatusViewModel.swift
//  Weibo项目
//
//  Created by vn on 16/7/23.
//  Copyright © 2016年 vn. All rights reserved.
//

import UIKit

//此ViewModel为cell服务
class StatusViewModel: NSObject {
    
    //定义一个Model属性
    var homeModel:HomeVCModel?
    // 微博认证用户图片
    var avatarImage: UIImage?
    //处理会员等级图片
    var memberImage: UIImage?

    
    init(homeModel:HomeVCModel?) {
        
        super.init()
        self.homeModel = homeModel
        
        self.avatarImage = getavatarImage(homeModel?.user?.verified)
        self.memberImage = getMemberImage(homeModel?.user?.mbrank)
        
    }
    
    
   
    //微博认证处理方法
    // 处理微博认证用户图片/// 认证类型 -1：没有认证，1，认证用户，2,3,5: 企业认证，220: 达人
    func getavatarImage(verified:Int?)->UIImage?{
        
        guard let v = verified else{
            
            return nil
            
        }
        
        switch v {
            
        case 1:
            
            return UIImage(named:"avatar_vip")
            
        case 2,3,5:
            
            return UIImage(named:"avatar_enterprise_vip")
            
        case 220:
            
            return UIImage(named:"avatar_grassroot")
            
            
        default:
            return UIImage(named:"avatar_vgirl")
            
            
        }
        
    }
    
    
    //处理用户等级
    func getMemberImage(mbrank:Int?) ->UIImage?{
        
         // 处理会员等级图片/// 会员等级 1-6
         guard let mb = mbrank else{
            
            return nil
            
        }
        
        
        if mb > 0 && mb < 7{
            
        return UIImage(named:"common_icon_membership_level\(mb)")
            
        }
        
        return UIImage(named:"common_icon_membership")
        
        
    }
    
    
}
